package lt.ntec.danblog.server.blog.util;

public class PostUtils {

    public static String generatePreviewString(String content, int length) {
        if (length > content.length()) {
            return content;
        }
        int index = content.indexOf(" ", length);
        if (index == -1) {
            return content;
        }
        return content.substring(0, index);
    }

    public static String generateUrlString(String title) {
        title = title.replaceAll("[\\s]", "_");
        title = title.replaceAll("[^\\w_\\-]", "");
        return title.toLowerCase();
    }
}
